<div class="page-middle page-middle-padding">
    <h2 class="menu_select">Contact Us</h2>
    <p class="address">    
    <span>Addresss:</span> #19AE0, Street 282, BKK1, Phnom Penh
    <br>
    <span>Tel:</span> (+855) 97 345 85 85, (+855) 12 388 848<br>    
    </p>
    <br>
    
    <?php        
        echo $this->Form->create('ContactUs', array('onSubmit' => 'return Validate()'));
        echo $this->Form->input('name',array('class' => 'required', 'label' => array('class'=>'contact_label','text' => 'Customer Name (<span class="star_required">*</span>)')));
        echo $this->Form->input('email',array('class' => 'required', 'label' => array('class'=>'contact_label','text' => 'Email (<span class="star_required">*</span>)')));
        echo $this->Form->input('phone',array('label' => array('class'=>'contact_label','text' => 'Phone')));
        echo $this->Form->input('subject',array('class' => 'required', 'label' => array('class'=>'contact_label','text' => 'Subject (<span class="star_required">*</span>)')));
        echo $this->Form->input('message',array('class' => 'required', 'type' => 'textarea', 'label'  => array('class'=>'contact_label','text' => 'Message (<span class="star_required">*</span>)')));
    ?>
    <?php echo $this->Form->end('Submit') ?> 
    
</div>
<script>
   function Validate(){
       var help = 0;
       $('.required').each(function(){           
            if($(this).val() == ""){
                $(this).next().remove();
		$(this).parent().append('<span class="confirm">This field is required.</span>');
                help = 0;
            }else{
                $(this).next().remove();
                help = 1;
            }
       })
       if(help == 1){
            var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
            var emailaddressVal = $("#ContactUsEmail").val();
            if(!emailReg.test(emailaddressVal)) {
                $("#ContactUsEmail").next().remove();
		$("#ContactUsEmail").parent().append('<span class="confirm">Invalid email.</span>');
                help = 0;
            }
       }
       if(help == 1) return true;
       else return false;
   }
</script>